package cn.fl.system.job.impl;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cmm.mid.core.framework.condition.CacheRefreshPropertiesQC;
import cn.cmm.base.framework.utils.BaseLogUtils;
import cn.fl.system.job.IJobService;
import cn.fl.system.service.ISysPropertiesService;

/**
 * 系统级别任务,如果其它业务上有需要定时器的需要,请参考本接口去自己的service中写自己的接口并实现
 * @author FUJINGRUN
 */
@Service
public class JobServiceImpl implements IJobService {
	

	/**
	 * Log
	 */
	private static final Logger logger = LoggerFactory.getLogger(JobServiceImpl.class);
	
	/**
	 * 属性文件服务
	 */
	@Autowired
	private ISysPropertiesService sysPropertiesService;

	private Thread thread = null;
	
	@Override
	public void execute() {
		DoRunnable doRunnable = new DoRunnable();
		thread = new Thread(doRunnable);
		thread.setDaemon(true);
		thread.start();
		//ThreadPoolUtils.submitTask(doRunnable);
	}
	
	/**
	* @ClassName: DoRunnable 
	* @Description:  线程处理
	 */
	private class DoRunnable implements Runnable{

		@Override
		public void run() {
			init();
		}
	}
	
	/**
	* @Title: INIT 
	* @Description: 业务处理
	 */
	private void init(){
		
		BaseLogUtils.info(logger, "init", "JOB定时器启动");
		
		this.sysPropertiesService.refresh(new CacheRefreshPropertiesQC());
		
		BaseLogUtils.info(logger, "init", "JOB定时器停止");
	}
}
